#include "StdThread.h"
#include <stdio.h>
#include <unistd.h>


Mutex*m;

void * func(void *arg)
{   
    int *count = (int*)arg;
    for(int i = 0;i < 10000;i++)
    {   
        MutexLock(m);
        (*count)++;
        MutexUnlock(m);
        
    }
}

void * func2(void *arg)
{   
    int *count = (int*)arg;
    for(int i = 0;i < 10000;i++)
    {   
        MutexLock(m);
        (*count)++;
        MutexUnlock(m);
        
    }
}
int main()
{   
    m = MutexInit();
    int count = 0;
    Thread* t1 = ThreadInit(func,&count);
    Thread* t2 = ThreadInit(func,&count);

    ThreadJoin(t1);
    ThreadJoin(t2);

    printf("count:%d\n",count);

    ClearMutex(m);
    ClearThread(t1);
    ClearThread(t2);

    return 0;
}